home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / despereaux-swings.swf / scripts / Box2D / Common / Math / b2Vec2.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  3.4 KB  |  156 lines

  1. package Box2D.Common.Math
  2. {
  3.    public class b2Vec2
  4.    {
  5.        
  6.       
  7.       public var x:Number;
  8.       
  9.       public var y:Number;
  10.       
  11.       public function b2Vec2(param1:Number = 0, param2:Number = 0)
  12.       {
  13.          super();
  14.          x = param1;
  15.          y = param2;
  16.       }
  17.       
  18.       public static function Make(param1:Number, param2:Number) : b2Vec2
  19.       {
  20.          return new b2Vec2(param1,param2);
  21.       }
  22.       
  23.       public function Set(param1:Number = 0, param2:Number = 0) : void
  24.       {
  25.          x = param1;
  26.          y = param2;
  27.       }
  28.       
  29.       public function Multiply(param1:Number) : void
  30.       {
  31.          x *= param1;
  32.          y *= param1;
  33.       }
  34.       
  35.       public function Length() : Number
  36.       {
  37.          return Math.sqrt(x * x + y * y);
  38.       }
  39.       
  40.       public function LengthSquared() : Number
  41.       {
  42.          return x * x + y * y;
  43.       }
  44.       
  45.       public function SetZero() : void
  46.       {
  47.          x = 0;
  48.          y = 0;
  49.       }
  50.       
  51.       public function Add(param1:b2Vec2) : void
  52.       {
  53.          x += param1.x;
  54.          y += param1.y;
  55.       }
  56.       
  57.       public function MaxV(param1:b2Vec2) : void
  58.       {
  59.          x = x > param1.x ? x : param1.x;
  60.          y = y > param1.y ? y : param1.y;
  61.       }
  62.       
  63.       public function SetV(param1:b2Vec2) : void
  64.       {
  65.          x = param1.x;
  66.          y = param1.y;
  67.       }
  68.       
  69.       public function Negative() : b2Vec2
  70.       {
  71.          return new b2Vec2(-x,-y);
  72.       }
  73.       
  74.       public function CrossVF(param1:Number) : void
  75.       {
  76.          var _loc2_:Number = NaN;
  77.          _loc2_ = x;
  78.          x = param1 * y;
  79.          y = -param1 * _loc2_;
  80.       }
  81.       
  82.       public function Abs() : void
  83.       {
  84.          if(x < 0)
  85.          {
  86.             x = -x;
  87.          }
  88.          if(y < 0)
  89.          {
  90.             y = -y;
  91.          }
  92.       }
  93.       
  94.       public function Copy() : b2Vec2
  95.       {
  96.          return new b2Vec2(x,y);
  97.       }
  98.       
  99.       public function MulTM(param1:b2Mat22) : void
  100.       {
  101.          var _loc2_:Number = NaN;
  102.          _loc2_ = b2Math.b2Dot(this,param1.col1);
  103.          y = b2Math.b2Dot(this,param1.col2);
  104.          x = _loc2_;
  105.       }
  106.       
  107.       public function IsValid() : Boolean
  108.       {
  109.          return b2Math.b2IsValid(x) && b2Math.b2IsValid(y);
  110.       }
  111.       
  112.       public function MinV(param1:b2Vec2) : void
  113.       {
  114.          x = x < param1.x ? x : param1.x;
  115.          y = y < param1.y ? y : param1.y;
  116.       }
  117.       
  118.       public function MulM(param1:b2Mat22) : void
  119.       {
  120.          var _loc2_:Number = NaN;
  121.          _loc2_ = x;
  122.          x = param1.col1.x * _loc2_ + param1.col2.x * y;
  123.          y = param1.col1.y * _loc2_ + param1.col2.y * y;
  124.       }
  125.       
  126.       public function Normalize() : Number
  127.       {
  128.          var _loc1_:Number = NaN;
  129.          var _loc2_:Number = NaN;
  130.          _loc1_ = Math.sqrt(x * x + y * y);
  131.          if(_loc1_ < Number.MIN_VALUE)
  132.          {
  133.             return 0;
  134.          }
  135.          _loc2_ = 1 / _loc1_;
  136.          x *= _loc2_;
  137.          y *= _loc2_;
  138.          return _loc1_;
  139.       }
  140.       
  141.       public function Subtract(param1:b2Vec2) : void
  142.       {
  143.          x -= param1.x;
  144.          y -= param1.y;
  145.       }
  146.       
  147.       public function CrossFV(param1:Number) : void
  148.       {
  149.          var _loc2_:Number = NaN;
  150.          _loc2_ = x;
  151.          x = -param1 * y;
  152.          y = param1 * _loc2_;
  153.       }
  154.    }
  155. }
  156.